package cn.cangli.mapper;

import cn.cangli.pojo.Emp;
import cn.cangli.pojo.EmpQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Many;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


    List<Emp> pageList(EmpQuery empQuery);

//    @Select("select count(*) from emp")
//    Long Count();
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into " +
            "emp(username, name, gender, phone, job_id, salary, image, entry_date, dept_id, create_time, update_time) " +
            "value (#{username}, #{name}, #{gender}, #{phone}, #{job_id}, #{salary}, #{image}, #{entryDate}, #{deptId}, #{createTime}, #{updateTime})")
    void save(Emp emp);

    //修改员工
    int update(Emp emp);

    //删除员工
    void deleteByIds(List<Integer> id);

    //确认手机号
    @Select("select count(*) from emp where phone=#{phone}")
    Integer checkPhone(String phone);


    Emp getById(Integer id);

    /**
     * 统计员工职位人数
     */
    @MapKey("pom")
    List<Map<String,Object>> countEmpJobData();

    @MapKey("pom")
    List<Map<String,Object>> countEmpDeptData();

    @MapKey("pom")
    List<Map<String,Object>> countGenderData();
}
